package data.selection;

import java.awt.Color;

import data.Player;
import data.Position;

import engine.ActionManager;

/**
 * Selection highlight to be used with the Throw action. Shows the throw template.
 * @author Julien
 *
 */
public class ThrowSelectionObject extends SelectionObject {
	Position thrower;
	
	/**
	 * Constructs the selection object around the player.
	 * @param player The player throwing the ball.
	 */
	public ThrowSelectionObject( Player player )
	{
		super();
		thrower = player;
	}
	
	/**
	 * Checks if the given position is affected by this selection object
	 * @return True if it is affected, false otherwise.
	 */
	public boolean isSelected( Position pos )
	{
		return (color(pos) != null);
	}
	
	/**
	 * Returns the color of the given position as seen from this selection object.
	 * Specifically, returns null for positions not impacted by this object.
	 * @return Color the color of the highlight
	 */
	public Color color( Position pos )
	{
		int distance = thrower.distance(pos);
		
		if( distance <= ActionManager.RULER_QUICK_PASS )
			return new Color( 0.0f, 1.0f, 0.0f, 0.25f );
		else if( distance <= ActionManager.RULER_SHORT_PASS )
			return new Color( 0.0f, 0.5f, 0.0f, 0.25f );
		else if( distance <= ActionManager.RULER_LONG_PASS )
			return new Color( 1.0f, 0.5f, 0.0f, 0.25f );
		else if( distance <= ActionManager.RULER_LONG_BOMB )
			return new Color( 1.0f, 0.0f, 0.0f, 0.25f );
		else
			return null;
	}
}